package com.leo.common.core.exception;

import com.leo.common.core.enums.ExceptionCodeEnum;
import com.leo.common.core.util.MessageUtils;
import com.leo.common.core.util.SpringContextHolder;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @program: pigx
 * @description: 业务异常
 * @author: Wen.Li
 * @create: 2019-10-23 08:08
 **/
@NoArgsConstructor
public class BizCodeException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	@Getter
	private ExceptionCodeEnum exceptionCodeEnum;

	public BizCodeException(ExceptionCodeEnum exceptionCodeEnum) {
		super(SpringContextHolder.getBean(MessageUtils.class).get(exceptionCodeEnum.getMsg()));
		this.exceptionCodeEnum = exceptionCodeEnum;
	}

	public BizCodeException(String message) {
		super(SpringContextHolder.getBean(MessageUtils.class).get(message));
	}

	public BizCodeException(Throwable cause) {
		super(cause);
	}

	public BizCodeException(String message, Throwable cause) {
		super(SpringContextHolder.getBean(MessageUtils.class).get(message), cause);
	}

	public BizCodeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super(SpringContextHolder.getBean(MessageUtils.class).get(message), cause, enableSuppression,
				writableStackTrace);
	}

}
